package com.xwj.listener;

import com.netflix.appinfo.InstanceInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * @author xwj
 * @date 2021/3/19
 */
@Component
@Slf4j
public class EurekaStateChangeListener {
    /**
     * 监听服务上线事件
     *
     * @param event
     */
    @EventListener
    public void listenerRegistered(EurekaInstanceRegisteredEvent event) {
        InstanceInfo instanceInfo = event.getInstanceInfo();
        log.info(instanceInfo.toString() + "上线");
    }
}
